﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Mrc.Config
{
    public class LocationHostStore
    {
        private static Dictionary<string, object> KeyValue { get; set; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);

        public static void Set(string name, object value)
        {
            if (KeyValue.ContainsKey(name))
            {
                KeyValue[name] = value;
            }
            else
            {
                KeyValue.Add(name, value);
            }
        }

        public static Dictionary<string, object> GetALL()
        {
            return KeyValue;
        }

        public static void Delete(string name)
        {
            if(KeyValue.ContainsKey(name))
            KeyValue.Remove(name);
        }

        public static T Get<T>(string name, T def = default(T))
        {
            if (!KeyValue.ContainsKey(name))
            {
                return def;
            }
            return (T)KeyValue[name];
        }
    }
}
